'use strict'

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    const { INTEGER, DATE, STRING } = Sequelize
    await queryInterface.createTable('product', {
      id: {
        type: INTEGER(20).UNSIGNED,
        primaryKey: true,
        autoIncrement: true,
        comment: '主键id'
      },
      detail_id: {
        type: INTEGER(20).UNSIGNED,
        allowNull: false,
        comment: '详情id',
        // references: {
        //   model: 'product_detail',
        //   key: 'id'
        // },
        onDelete: 'CASCADE'
      },
      title: {
        type: STRING(50),
        allowNull: false,
        comment: '商品名称'
      },
      poster: {
        type: STRING(200),
        allowNull: false,
        comment: '产品海报'
      },
      type: {
        type: STRING(50),
        allowNull: false,
        comment: '产品类型'
      },
      gitee_url: {
        type: STRING(200),
        allowNull: false,
        comment: 'gitee地址'
      },
      status: {
        type: INTEGER(4),
        allowNull: false,
        defaultValue: 1,
        comment: '状态:1:正常:0:删除'
      },
      created_at: DATE,
      updated_at: DATE
    })
  },

  async down(queryInterface) {
    queryInterface.dropTable('product')
  }
}
